home *** CD-ROM | disk | FTP | other *** search
/ Die Ultimative Software-P…i Collection 1996 & 1997 / Die Ultimative Software-Pakete CD-ROM fur Atari Collection 1996 & 1997.iso / g / gnu_c / pmllib21.zoo / ccos.c.orig < prev    next >
Encoding:
Text File  |  1992-04-01  |  4.1 KB  |  196 lines

  1. /************************************************************************
  2.  *                                    *
  3.  *                N O T I C E                *
  4.  *                                    *
  5.  *            Copyright Abandoned, 1987, Fred Fish        *
  6.  *                                    *
  7.  *    This previously copyrighted work has been placed into the    *
  8.  *    public domain by the author (Fred Fish) and may be freely used    *
  9.  *    for any purpose, private or commercial.  I would appreciate    *
  10.  *    it, as a courtesy, if this notice is left in all copies and    *
  11.  *    derivative works.  Thank you, and enjoy...            *
  12.  *                                    *
  13.  *    The author makes no warranty of any kind with respect to this    *
  14.  *    product and explicitly disclaims any implied warranties of    *
  15.  *    merchantability or fitness for any particular purpose.        *
  16.  *                                    *
  17.  ************************************************************************
  18.  */
  19.  
  20. /*
  21.  *  FUNCTION
  22.  *
  23.  *    ccos   complex double precision cosine
  24.  *
  25.  *  KEY WORDS
  26.  *
  27.  *    ccos
  28.  *    complex functions
  29.  *    machine independent routines
  30.  *    math libraries
  31.  *
  32.  *  DESCRIPTION
  33.  *
  34.  *    Computes double precision complex cosine of a double
  35.  *    precision complex argument.
  36.  *
  37.  *  USAGE
  38.  *
  39.  *    COMPLEX ccos (z)
  40.  *    COMPLEX z;
  41.  *
  42.  *  REFERENCES
  43.  *
  44.  *    Fortran 77 user's guide, Digital Equipment Corp. pp B-12
  45.  *
  46.  *  PROGRAMMER
  47.  *    
  48.  *    Fred Fish
  49.  *    Tempe, Az 85281
  50.  *    (602) 966-8871
  51.  *
  52.  *  INTERNALS
  53.  *
  54.  *    Computes complex cosine of z = x + j y from:
  55.  *
  56.  *        1.    r_ccos = cos(x) * cosh(y)
  57.  *
  58.  *        2.    i_ccos = -sin(x) * sinh(y)
  59.  *
  60.  *        3.    ccos(z) = r_ccos + j i_ccos
  61.  *
  62.  */
  63.  
  64. #if !defined (__M68881__) && !defined (sfp004)
  65.  
  66. #include <stdio.h>
  67. #include <math.h>
  68. #include "pml.h"
  69.  
  70.  
  71. COMPLEX ccos (z)
  72. COMPLEX z;
  73. {
  74.     COMPLEX result;
  75.  
  76.     result.real = cos(z.real) * cosh(z.imag);
  77.     result.imag = -sin(z.real) * sinh(z.imag);
  78.     return (result);
  79. }
  80. #endif !defined (__M68881__) && !defined (sfp004)
  81.  
  82. #ifdef    __M68881__
  83. __asm("
  84. .text
  85. _funcname:
  86.     .ascii    \"ccos\\0\"
  87.     .even
  88.     .globl _ccos
  89. _ccos:
  90.     movel    a1,d0        | save a1 as return value
  91.     fmoved    sp@(4),fp0    | z.real
  92.     fsinx    fp0,fp1        | cos(z.real)
  93.     fcosx    fp0,fp0        | sin(z.real)
  94.     fnegx    fp1,fp1        |-sin(z.real)
  95.  
  96.     fmoved    sp@(12),fp3    | z.imag
  97.     fcoshx    fp3,fp2        | cosh(z.imag)
  98.     fsinhx    fp3,fp3        | sinh(z.imag)
  99.     
  100.     fmulx    fp2,fp0        | result.real
  101.     fmoved    fp0,a1@        |
  102.     fmulx    fp3,fp1        | result.imag
  103.     fmoved    fp1,a1@(8)    |
  104. ");    /* end asm    */
  105. #endif    __M68881__
  106.  
  107. #ifdef    sfp004
  108. __asm("
  109. | double precision floating point stuff for Atari-gcc using the SFP004
  110. | developed with gas
  111. |
  112. | double precision complex sin
  113. |
  114. | M. Ritzert (mjr at dmzrzu71)
  115. |
  116. | 12.10.1990
  117. |
  118. | addresses of the 68881 data port. This choice is fastest when much data is
  119. | transferred between the two processors.
  120.  
  121. comm =     -6
  122. resp =    -16
  123. zahl =      0
  124.  
  125. | waiting loop ...
  126. |
  127. | wait:
  128. | ww:    cmpiw    #0x8900,a1@(resp)
  129. |     beq    ww
  130. | is coded directly by
  131. |    .long    0x0c688900, 0xfff067f8
  132. | and
  133. | www:    tst.b    a1@(resp)
  134. |    bmi.b    www
  135. | is coded by
  136. |    .word    0x4a68,0xfff0,0x6bfa        | test
  137.  
  138.     .text; .even
  139.     .globl _ccos
  140. _ccos:
  141.     movel    a1,d0                | save a1 as return value
  142.     lea    0xfffa50,a0            | fpu address
  143.  
  144.     movew    #0x54b0,a0@(comm)        | sincos: sin -> fp1
  145.     .long    0x0c688900, 0xfff067f8        |      cos -> fp0
  146.     movel    sp@(4), a0@            | load z.real
  147.     movel    sp@(8), a0@            | load z.real
  148.  
  149. |    fmoved    sp@(12),fp3            | z.imag to fp3
  150.     movew    #0x5580,a0@(comm)
  151.     .long    0x0c688900, 0xfff067f8
  152.     movel    sp@(12),a0@
  153.     movel    sp@(16),a0@
  154.  
  155. |    fcoshx    fp3,fp2                | cosh(z.imag)
  156.     movew    #0x0d19,a0@(comm)
  157.     .word    0x4a68,0xfff0,0x6bfa        | test
  158. |    fsinhx    fp3,fp3                | sinh(z.imag)
  159.     movew    #0x0d82,a0@(comm)
  160.     .word    0x4a68,0xfff0,0x6bfa        | test
  161. |    fmulx    fp2,fp0                | result.real
  162.     movew    #0x0823,a0@(comm)
  163.     .word    0x4a68,0xfff0,0x6bfa        | test
  164. |    fmoved    fp0,a1@                |
  165.     movew    #0x7400,a0@(comm)        | 
  166.     .long    0x0c688900, 0xfff067f8
  167.     movel    a0@,a1@
  168.     movel    a0@,a1@(4)
  169. |    fmulx    fp3,fp1                | result.imag
  170.     movew    #0x0ca3,a0@(comm)
  171.     .word    0x4a68,0xfff0,0x6bfa        | test
  172. |    fnegx    fp1,fp1
  173.     movew    #0x049a,a0@(comm)
  174.     .word    0x4a68,0xfff0,0x6bfa        | test
  175. |    fmoves    fp1,d1                |
  176.     movew    #0x7480,a0@(comm)        |
  177.     .long    0x0c688900, 0xfff067f8
  178.     movel    a0@,a1@(8)
  179.     movel    a0@,a1@(12)
  180. ");    /* end asm    */
  181. #endif    sfp004
  182.  
  183.  
  184. #if defined (__M68881__) || defined (sfp004)
  185. # ifdef ERROR_CHECK    /* no error checking for now    */
  186. __asm("
  187.     pea    _funcname
  188.     jmp    c_err_check
  189. ");    /* end asm    */
  190. # else  ERROR_CHECK
  191.  
  192. __asm("rts");
  193.  
  194. # endif ERROR_CHECK
  195. #endif defined (__M68881__) || defined (sfp004)
  196.